// 用户相关API
import request from '@/utils/request.js'

/**
 * 发送短信验证码
 * @param {String} phone 手机号
 */
export const sendSms = (phone) => {
  return request({
    url: `/agg/sms/send?phone=${phone}`,
    method: 'GET'
  })
}

/**
 * 用户登录（手机号+验证码）
 * @param {Object} data { phone, code }
 */
export const login = (data) => {
  return request({
    url: '/agg/user/appLogin',
    method: 'POST',
    data: data
  })
}

/**
 * 获取当前用户信息
 */
export const getCurrentUser = () => {
  return request({
    url: '/agg/user/current',
    method: 'GET'
  })
}

/**
 * 获取用户账户信息
 */
export const getCurrentAccount = () => {
  return request({
    url: '/agg/account/current',
    method: 'GET'
  })
}

/**
 * 修改用户信息
 * @param {Object} data { name, avatar, email }
 */
export const editUserInfo = (data) => {
  return request({
    url: '/agg/user/edit',
    method: 'POST',
    data: data
  })
}

